/**
 * 
 */
package net.penguinmenac3.archivedb;

import java.util.Scanner;

/**
 * @author Michael
 * 
 */
public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArchiveDB a = new ArchiveDB();

		String[] keys = { "key" };
		/*if (!a.push(new Entry(200, "foobra.txt", keys, "you got pwned", 0,
				false, "abc", 0, FT.TXT))) {
			System.out.println("Push: failed!");
		}*/

		String[] search = args;

		while (true) {
			if (args == null || args.length == 0) {
				Scanner sc = new Scanner(System.in);
				System.out.println("**********************************************");
				System.out.println("Insert what you want to search:");
				String input = sc.nextLine();
				String[] arg2 = { input };
				search = arg2;
			}

			long timer = System.nanoTime();
			Key[] morekeys = a.getMoreRelatedKeywords(search, FT.TXT);
			timer = System.nanoTime() - timer;
			System.out.println("Found " + morekeys.length
					+ " possibilities!  (in " + (timer / 1000) / 1000.0
					+ " ms)");
			/*for (Key k : morekeys) {
				System.out.println(k.name + "(" + k.count + ")");
			}*/

			System.out.println("Searching for '" + search[0] + "'");
			timer = System.nanoTime();
			Entry[] entries = a.search(search, FT.TXT, false, 10);
			timer = System.nanoTime() - timer;

			System.out.println("Found " + entries.length + " results! (in "
					+ (timer / 1000) / 1000.0 + " ms)");
			for (Entry e : entries) {
				System.out.println("ID:" + e.ID + " | file:" + e.filename
						+ " | descript:" + e.description + " | rating:"
						+ e.rating + " | local:" + e.local + " | relevance:"
						+ e.relevance + " | filetype:" + e.filetype
						+ " | fulltext:" + e.fulltext);
			}
			args = null;
		}
		// System.out.println("Delete: "+a.delete(0));
	}

}
